package gui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFileChooser;

public class LoadButton extends JButton implements ActionListener{
	
	private CompareButton compare;


	public LoadButton(CompareButton compare){
		super("Load");
		addActionListener(this);
		this.compare = compare;
	}


	public void actionPerformed(ActionEvent e) {
		
		JFileChooser chooser = new JFileChooser();
		chooser.setDialogTitle("Please choose a .arff file containing old projects.");
		
		if(chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION){
			String fileName = chooser.getSelectedFile().getAbsolutePath();
//			try {
//				ArrayList<Project> pro = ARFFReader.parse(fileName);
//				ArrayList<ProjectPropertyDescriptor> prop = ARFFReader.getProjectDescriptors(fileName);
				
				compare.setDataSource(fileName);
//				System.out.println(Arrays.toString(pro.toArray(new Project[]{})));
				
				
//				for(int i=0; i<pro.size(); i++){
//					Database.instance().addProject(pro.get(i));
//				}
				
//			} catch (FileNotFoundException e1) {
//				e1.printStackTrace();
//			} catch (IOException e1) {	
//				e1.printStackTrace();
//			}
		}
		
		
	}

}
